package com.aglhz.nature.view;

import java.io.UnsupportedEncodingException;

import com.aglhz.nature.R;
import com.aglhz.nature.view.touxiang.CircularImage;
import com.squareup.picasso.Picasso;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
/**
 * 修改个人资料
 * @author Administrator
 *
 */
public class ChangePesonDataActivity extends Activity implements OnClickListener{
	private SharedPreferences sharedPreferences,shPreferences;
	private Button personData;
	private LinearLayout back;
	private CircularImage user_photo;
	private  EditText change_et_name;
	private  TextView user_number;
	private  TextView user_password;
	private String rightName;
	private String name;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
	
		super.onCreate(savedInstanceState);
		setContentView(R.layout.chagneperson);
		sharedPreferences = getSharedPreferences("ALLUSER_INFO",Context.MODE_PRIVATE); 
		shPreferences= getSharedPreferences("EditText_Info",
				Context.MODE_PRIVATE);
		personData=(Button) findViewById(R.id.personData);
		back=(LinearLayout) findViewById(R.id.back);
		user_photo=(CircularImage) findViewById(R.id.user_photo);
		change_et_name=(EditText) findViewById(R.id.change_et_name);
		user_number=(TextView) findViewById(R.id.user_number);
		user_password=(TextView) findViewById(R.id.user_password);
//		picasso加载网络图片
		   Picasso.with(ChangePesonDataActivity.this)  
		   .load(sharedPreferences.getString("icon", ""))  	    	               
		   .into(user_photo) ;
		   name= sharedPreferences.getString("name", "");
		   try {
			rightName = new String(name.getBytes("ISO-8859-1"), "utf-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		   change_et_name.setText(rightName);
		   user_number.setText(shPreferences.getString("NORMAL_ACCOUNT", ""));
		   
		 personData.setOnClickListener(this);
		 user_password.setOnClickListener(this);
		 back.setOnClickListener(this);
	}
	@Override
	public void onClick(View arg0) {
		Intent intent;
		switch (arg0.getId()) {
		case R.id.user_password:
			 intent =new Intent(ChangePesonDataActivity.this,ChangePaswordActivity.class);
			startActivity(intent);
			break;
		//PersonDataActivity.class
		case R.id.personData:
			intent =new Intent(ChangePesonDataActivity.this,ChangePaswordActivity.class);
			startActivity(intent);
			break;
		case R.id.back:
			finish();
			break;
		default:
			break;
		}
		
	}

}
